<taglib name="Admin\TagLib\EasyUI" />

<easyui:datagrid options="datagrid.options" fields="datagrid.fields" />

<!-- 查看任务 -->
<div id="report_reportlist_view_dialog" class="easyui-dialog" title="举报处理"
     data-options="modal:true,closed:true,iconCls:'icons-application-application_view_detail',
     buttons:[{text:'关闭',iconCls:'icons-arrow-cross',
     handler:function(){$('#report_reportlist_view_dialog').dialog('close');}}]"
     style="width:500px;height:320px;"></div>

<!-- 查看用户 -->
<div id="member_memberlist_view_dialog" class="easyui-dialog" title="用户详情" data-options="modal:true,closed:true,iconCls:'icons-application-application_view_detail',buttons:[{text:'关闭',iconCls:'icons-arrow-cross',handler:function(){$('#member_memberlist_view_dialog').dialog('close');}}]" style="width:450px;height:330px;"></div>


<script type="text/javascript">
    var report_reportlist_datagrid_toolbar = [
        { text: '刷新', iconCls: 'icons-table-table_refresh', handler: reportReportRefresh }
    ];

    //刷新
    function reportReportRefresh(){
        $('#report_reportlist_datagrid').datagrid('reload');
    }

    function reportListOperateFormatter(val){
        var btn = [];
        btn.push('<a href="javascript:;" onclick="reportDeal('+val+')">处理</a>');
        btn.push('<a href="javascript:;" onclick="reportDelete('+val+')">删除</a>');
        return btn.join(' | ');
    }

    function nameFormatter(val){
        var value = '000';
         $.ajax({
            url:'<{:U('Report/getNameById')}>&id='+val,
            type: 'GET',
            data: {},
            timeout: 3000,
            success: function (data) {

            value =  data;
            },
            async: false
        });
        var info = '<a href="javascript:;" onclick="viewUser('+val+')">'+value+'</a>'
        return info;
    }

    function sugFormatter(val){
        if(val==0){
            return "未处理";
        }else if(val==1){
            return "已处理";
        }
    }


    function viewUser(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择用户', 'error');
            return false;
        }
        var url = '<{:U('Member/memberView')}>';
        url += url.indexOf('?') != -1 ? '&id='+id : '?id='+id;
        $('#member_memberlist_view_dialog').dialog({href:url});
        $('#member_memberlist_view_dialog').dialog('open');

    }
    function reportDeal(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择用户', 'error');
            return false;
        }
        var url = '<{:U('Report/reportDeal')}>';
        url += url.indexOf('?') != -1 ? '&report_id='+id : '?report_id='+id;
        $('#report_reportlist_view_dialog').dialog({href:url});
        $('#report_reportlist_view_dialog').dialog('open');
    }


    function reportDelete(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择', 'error');
            return false;
        }
        $.messager.confirm('提示信息', '确定要删除吗？', function(result){
            if(!result) return false;
            $.post('<{:U('Report/reportDelete')}>', {report_id: id}, function(res){
                if(!res.status){
                    $.messager.alert('提示信息', res.info, 'error');
                }else{
                    $.messager.alert('提示信息', res.info, 'info');
                    reportReportRefresh();
                }
            }, 'json');
        });

    }

</script>